<?php
/**
 * 内容管理视图
 *
 *
 *
 */
// 排序
$arr_orderby    = array(
    'uid'        => '&orderby=uid',
    'attr'  => '&orderby=attr',
    'regdate'=> '&orderby=regdate',
    'end_time'  => '&orderby=end_time',
    'display'  => '&orderby=display',
    'num'       => '&orderby=num',
    'balance'    => '&orderby=balance',
    );
$orderby    = strtolower(trim(@$_GET['orderby']));
if(array_key_exists($orderby, $arr_orderby)) {
    $order_asc  = @(int)$_GET['desc'];
    $arr_orderby[$orderby] .= $order_asc == 0 ? '&desc=1' : '&desc=0';
} else {
    $arr_orderby['uid'] .= '&desc=0';
}

// 保存数据框架名
$save_frame = $_SESSION[$G_admin_session_key]['save_frame'];
$back_url   = get_current_url();
// 将当前URL保存在Cookie中，避免复杂的URL字符串
cookie('back_url', strcode($back_url));
$url_cur    = get_current_url(array('orderby', 'desc'));


/**
 * 搜索参数处理
 *
 */
// 关键字
$key            = trim(@$_GET['key']);
// 是否包含子类
$class_id       = @(int)$_GET['class_id'];
$class_all      = @(int)$_GET['class_all'];
$chk_class_all  = ($class_all==1) ? ' checked' : '';
// 是否有效
$type       = trim(@$_GET['type']);
if($type == 1) {
    $chk_type_1 = ' checked';
} elseif($type == 2) {
    $chk_type_2 = ' checked';
} elseif($type == 3) {
    $chk_type_3 = ' checked';
} elseif($type == 4) {
    $chk_type_4 = ' checked';
} elseif($type == 5) {
    $chk_type_5 = ' checked';
} else {
    $chk_type_all = ' checked';
}


$begin_date = @$_GET['begin_date'];
$end_date   = @$_GET['end_date'];
$is_ad      = @(int)$_GET['is_ad'];

$dsp_ad     = ($is_ad == 1) ? 'style="display:block"':'style="display:none"';



$chk_haveimg    = @(int)$_GET['haveimg'] == 1 ? ' checked':'';
$chk_top        = @(int)$_GET['top'] == 1 ? ' checked':'';
$chk_new        = @(int)$_GET['new'] == 1 ? ' checked':'';
$chk_recommend  = @(int)$_GET['recommend'] == 1 ? ' checked':'';



// + -------------------------------------- + //
// 排序处理 - 为排序加上小图标

$order_by   = @trim($_GET['orderby']);
$order_desc = @(int)$_GET['desc'];

if($order_by != '') {
    $order_desc = ($order_desc!=1) ? 'sort_asc' : 'sort_desc' ;
    $this_param_style  = $order_by . '_style';
    $$this_param_style = '<div class="' . $order_desc . '"></div>';
}
     
		
// + -------------------------------------- + //

require($abs_admin_cppath . '/header.php');
?>
<SCRIPT LANGUAGE="JavaScript" SRC="<?php echo $url_global['common']; ?>/js/popcalendar.js"></SCRIPT>
<div class="sp_height_5px"></div>
<div class="datacontainer1" id="listDiv">
<form action="<?php echo $mod_url['li'] ?>" name="search" method="get">
<div class="new_line">
<input type="hidden" name="mod" value="<?php echo $mod ?>">
<input type="hidden" name="action" value="<?php echo $action ?>">
<input type="hidden" name="cata" value="<?php echo $cata ?>">



	<div class="spW10 fl"></div>
	<a href="<?php echo $mod_url['add'] ?>"  class="btn fl">新增会员</a>

&nbsp;&nbsp;
<input type="text" name="key" value="<?php echo $key?>" size="10" class="text">


	<input type="submit" value="查询" class="btn">
	&nbsp;&nbsp;
</div>
</form>
<form action="<?php echo $mod_url['del'] ?>" name="items_form" method="post" target="<?php echo $save_frame?>" onsubmit="return submit_select_items(this.name, 'item_id[]');">
<TABLE BORDER="0" cellpadding="4" cellspacing="1" width="100%" class="list_table">
<THEAD>
	<TR class="list_head">
		<TH scope=col width="30" class="textC"><a href="<?php echo $url_cur ?><?php echo $arr_orderby['uid'] ?>"><?php echo $uid_style;?>#</a></TH>
        <TH scope=col width="100">用户名</TH>
        <TH scope=col width="100">真实名</TH>
        <TH width="120" scope=col>手机号</TH>
        <TH width="80" scope=col><a href="<?php echo $url_cur ?><?php echo $arr_orderby['balance']; ?>"><?php echo $balance_style;?>黄金券</a></TH>
        <TH width="90" scope=col><a href="<?php echo $url_cur ?><?php echo $arr_orderby['attr']; ?>"><?php echo $attr_style;?>会员类别</a></TH>
		<TH scope=col width="90"><a href="<?php echo $url_cur ?><?php echo $arr_orderby['regdate'] ?>"><?php echo $regdate_style;?>注册时间</a></TH>
		<TH scope=col width="90"><a href="<?php echo $url_cur ?><?php echo $arr_orderby['display']; ?>"><?php echo $display_style;?>状态</a></TH>
		<TH scope=col width="70">操作</TH></TR></THEAD>
<TBODY>
<?php
$tr_class   = '';
if(!empty($record) && sizeof($record) > 0) {
    foreach($record as $k=>$v) {
        $tr_class   = $tr_class != 'tr0' ? 'tr0' : 'tr1';
        //$cname = (array_key_exists($v['cid'], $members_class)) ? $members_class[$v['cid']] : '&nbsp;';
        $title_full = htmlspecialchars($v['username']);
        $realname_full = htmlspecialchars($v['realname']);
        $title_cut  = zh_substr($title_full, 50);
        $realname_cut  = zh_substr($realname_full, 50);
        $txt_createtime = date('Y-m-d', $v['regdate']);
        $tel  = $v['tel'];
		$hjj  = $v['balance'];
		switch($v['attr']){
			case 1;
			$txt_usertype="普通会员";
			break;
			case 2;
			$txt_usertype="代理会员";
			break;
			case 3;
			$txt_usertype="服务会员";
			break;
			case 4;
			$txt_usertype="加盟会员";
			break;
		}

 if($v['display'] == 1) {
            $txt_display    = "<div class=\"btn_yes\" onclick=\"listTable.toggle(this, 'display', 1, '{$v['uid']}')\">{$v['display']}</div>";
        } else {
            $txt_display    = "<div class=\"btn_no\" onclick=\"listTable.toggle(this, 'display', 1, '{$v['uid']}')\">0</div>";
        }
?>
	<TR class="<?php echo $tr_class; ?>" onmouseover="return chgBg(this, 1);" onmouseout="return chgBg(this, 0);">
		<TD class="textC"><input type="checkbox" value="<?php echo $v['uid']; ?>" name="item_id[]"></TD>
        <TD>&nbsp;<?php echo $title_full; ?></TD>
        <TD>&nbsp;<?php echo $realname_cut; ?></TD>
        <TD>&nbsp;<?php echo $tel; ?></TD>
        <TD align="center"><?php echo $hjj; ?>张</TD>
		<TD class="time01 textC"><?php echo $txt_usertype; ?></TD>
		<TD class="time01 textC"><?php echo $txt_createtime; ?></TD>
		<TD align="center" class="time01 textC"><?php echo $txt_display; ?></TD>
		<TD>
			<a href="<?php echo $mod_url['modify'] ?>&uid=<?php echo $v['uid']; ?>" class="btn_modify fl" title="修改内容">修改</a>
			<a href="<?php echo $mod_url['del'] ?>&item_id=<?php echo $v['uid']; ?>" target="<?php echo $save_frame; ?>" onclick="return del_this();" class="btn_del fl" title="删除内容">删除</a>
            <a href="<?php echo $mod_url['cz'] ?>&uid=<?php echo $v['uid']; ?>" class="btn_cz fl" title="充值">充值</a>
		</TD></TR>
<?php
    }
} else {
?>
<TR class="tr0" onmouseover="return chgBg(this, 1);" onmouseout="return chgBg(this, 0);">
<TD colspan="6">没有或没有找到合适的记录！</td>
</td>
<?php
}
?>
</TBODY>
</TABLE>
<?php
// 分页
$page_info  = "$record_total 条记录 共 $page_total 页 ";
$page_list  = get_page_nav($page_total);
?>
<div class="page_nav">
	<div class="page_info">
		<?php echo $page_info ?>
	</div>
	<div class="page_list_pre">
		&nbsp;&nbsp;<a href="javascript:void(0);" onclick="chkbox_sel_all('items_form', 'item_id[]');"><B>全选</B></a> <a href="javascript:void(0);" onclick="chkbox_sel_reverse('items_form', 'item_id[]');"><B>反选</B></a>
	</div>
	<div class="page_list">
		<?php echo $page_list?>
	</div>
</div>
<div class="new_line">
<!--<input type="button" name="check" value=" 审核会员 " class="btn fl" onclick="return submit_select_items(this.form.name, 'item_id[]', '通过审核', '/admin/admin.php?mod=members&action=check');">-->
<input type="submit" name="del" value=" 删除 " class="btn fl" style="margin-left:10px;">
<input type="hidden" name="deltype" value="<?php echo $save_flag; ?>">

</div>
</form>
		</div>

</div>

<?php
require('footer.php');
?>